Start up functions

Read and organize data

read_srm_export <- function(filename, columns = c("peak_name", "RT.min", "basepeak", "area.cpm", "height.cts", "quantitation")) {
  filename %>% 
    # read excel files
    read_excel(sheet = "Integration", skip = 42, 
               col_names = columns, col_types = rep("text", length(columns))) %>% 
    as_data_frame() %>%
    # remove empty rows
    filter(!is.na(peak_name), peak_name != "n.a.") %>% 
    # convert the relevant numeric columns into numbers
    mutate_at(vars(RT.min, area.cpm, height.cts), as.numeric) %>% 
    # remove useless columns
    select(-basepeak, -quantitation) %>% 
    # add filename info
    mutate(file_id = gsub("\\.xls", "", basename(filename))) %>% 
    select(file_id, everything())
}

# get data
all_data <- 
  # find all excel files ##change name and use new folder for new project
  list.files("data_SH1", recursive = TRUE, full.names = TRUE, pattern = "\\.xls$") %>% 
  # send them to the read method
  lapply(read_srm_export) %>% 
  # combine the data set
  bind_rows() %>% 
  # pull out sample information
  #mutate(sample_id = str_match(all_data$file_id, "TSQ\\d+_GB_(.*)$") %>% { .[,2] }) %>% 
  # get n replicates
  group_by(file_id)
  #mutate(n_replicates = length(unique(file_id)))

File names for metadata file

Calculation peak amounts and rock concentrations, ID standards

depth_and_rock_info <- read_excel(file.path("metadata", "aliphaticSRM_SH1.xlsx")) %>% 
  rename(tle = `TLE.mg`, maltene = `maltenes.mg`, ref_amount_added.ug = `D4.ug` )%>% 
  filter(!is.na(file_id))%>%
  filter(process == "yes")
depth_and_rock_info
## # A tibble: 69 x 8
##    file_id       OG depth rock.g      tle maltene ref_amount_adde… process
##    <chr>      <dbl> <dbl>  <dbl>    <dbl>   <dbl>            <dbl> <chr>  
##  1 TSQ3481_G…  2.00   125  10.0    24.9     13.7               100 yes    
##  2 TSQ3482_G…  3.00   124  10.1   224        7.30              100 yes    
##  3 TSQ3483_G…  4.00   123  10.3  - 14.4      5.00              100 yes    
##  4 TSQ3484_G…  5.00   122   9.28    3.20     5.40              100 yes    
##  5 TSQ3485_G…  6.00   121  10.6    33.4     NA                 100 yes    
##  6 TSQ3486_G…  7.00   119   9.62 -214        4.80              100 yes    
##  7 TSQ3489_G…  8.00   118   9.70    3.40     5.00              100 yes    
##  8 TSQ3490_G…  9.00   117  10.7     5.00     6.30              100 yes    
##  9 TSQ3491_G… 10.0    115  11.1     5.00     6.00              100 yes    
## 10 TSQ3492_G… 11.0    114  10.2     0.400    6.90              100 yes    
## # ... with 59 more rows
data_by_depth <- 
  all_data %>%
  left_join(depth_and_rock_info, by = "file_id") %>% 
  group_by(file_id) %>% 
  mutate(
    n_peaks = n(),
    n_standards = sum(peak_name == "D4 C29 ISTD"),
    ref_area.cpm = area.cpm[peak_name == "D4 C29 ISTD"],
    amount.ug = area.cpm/ref_area.cpm * ref_amount_added.ug,
   
    #Normalize by what you want
    conc_rock.ug_g = amount.ug / rock.g, 
    conc_tle.ug.g = amount.ug / tle,  
    conc_maltene.ug.g = amount.ug / maltene
    
  )%>% ungroup() %>% 
  arrange(file_id, peak_name) 

data_by_depth
## # A tibble: 11,665 x 19
##    file_id  peak_name  RT.min area.cpm height.cts    OG depth rock.g   tle
##    <chr>    <chr>       <dbl>    <dbl>      <dbl> <dbl> <dbl>  <dbl> <dbl>
##  1 TSQ3466… 20R 4a,24…   34.7    42909     396389  22.0   102   11.0  4.50
##  2 TSQ3466… 20R, 4a M…   33.4    33439     425331  22.0   102   11.0  4.50
##  3 TSQ3466… 20R, 4a M…   32.8    49529     763046  22.0   102   11.0  4.50
##  4 TSQ3466… 20R, 4a,2…   35.3    26212     404760  22.0   102   11.0  4.50
##  5 TSQ3466… 20S, 4a M…   32.1    49207     882869  22.0   102   11.0  4.50
##  6 TSQ3466… 20S, 4a,2…   35.8    31831     268610  22.0   102   11.0  4.50
##  7 TSQ3466… 20S, 4a,2…   34.0    51613     456842  22.0   102   11.0  4.50
##  8 TSQ3466… 25-nor C2…   37.6    11915     155542  22.0   102   11.0  4.50
##  9 TSQ3466… 28, 30 C2…   37.0    27403     343070  22.0   102   11.0  4.50
## 10 TSQ3466… 29, 30 C2…   35.8     5780      63220  22.0   102   11.0  4.50
## # ... with 11,655 more rows, and 10 more variables: maltene <dbl>,
## #   ref_amount_added.ug <dbl>, process <chr>, n_peaks <int>,
## #   n_standards <int>, ref_area.cpm <dbl>, amount.ug <dbl>,
## #   conc_rock.ug_g <dbl>, conc_tle.ug.g <dbl>, conc_maltene.ug.g <dbl>

Calculate Recovery

Linear regressions of the calibration curves

standard <- read_excel(file.path("metadata", "D4_calibration.xlsx"))   ###read excel

###calibration curve
standard %>% 
  ggplot() +
  aes(x = Known.ng, y = Measured_area.counts, color = calibration) + 
  geom_smooth(method = "lm", alpha = 0.5) +
  geom_point() +
  theme_bw() +
  theme(legend.position = "none") 

calibrations <- 
  standard %>% 
  filter(!is.na(calibration)) %>% 
  nest(-calibration) %>% 
  mutate(
    fit = map(data, ~summary(lm(`Measured_area.counts`~ `Known.ng`, data = .x))),
    coefficients = map(fit, "coefficients"),
    intercept = map_dbl(coefficients, `[`, 1, 1),
    intercept_se = map_dbl(coefficients, `[`, 1, 2),
    slope = map_dbl(coefficients, `[`, 2, 1),
    slope_se = map_dbl(coefficients, `[`, 2, 2),
    r2 = map_dbl(fit, "r.squared")
  )

calibrations %>% select(-data, -fit, -coefficients) %>% knitr::kable(d = 3)
calibration intercept intercept_se slope slope_se r2
jan2018 705.862 1371.146 72929.67 3337.256 0.996

Determine yield

These numbers are not useful for anything else.

calib_data <-
  data_by_depth %>% 
  # temp
  mutate(calibration = "jan2018") %>% 
  left_join(calibrations, by = "calibration") %>% 
  mutate(
    total_volume.uL = 100,
    total_inject.uL = 1.5,
    ref_amount_inject_expected.ng = (ref_amount_added.ug * 1000)/total_volume.uL * total_inject.uL ,
    ref_amount_inject_measured.ng = (ref_area.cpm - intercept)/slope,
    ref_amount_measured.ug = ((total_volume.uL* ref_amount_inject_measured.ng)/total_inject.uL) * 1/1000,
    yield = (ref_amount_inject_measured.ng/ref_amount_inject_expected.ng) * 100
  ) %>% 
  filter(area.cpm > 700)

calib_data
## # A tibble: 7,614 x 34
##    file_id  peak_name  RT.min area.cpm height.cts    OG depth rock.g   tle
##    <chr>    <chr>       <dbl>    <dbl>      <dbl> <dbl> <dbl>  <dbl> <dbl>
##  1 TSQ3466… 20R 4a,24…   34.7    42909     396389  22.0   102   11.0  4.50
##  2 TSQ3466… 20R, 4a M…   33.4    33439     425331  22.0   102   11.0  4.50
##  3 TSQ3466… 20R, 4a M…   32.8    49529     763046  22.0   102   11.0  4.50
##  4 TSQ3466… 20R, 4a,2…   35.3    26212     404760  22.0   102   11.0  4.50
##  5 TSQ3466… 20S, 4a M…   32.1    49207     882869  22.0   102   11.0  4.50
##  6 TSQ3466… 20S, 4a,2…   35.8    31831     268610  22.0   102   11.0  4.50
##  7 TSQ3466… 20S, 4a,2…   34.0    51613     456842  22.0   102   11.0  4.50
##  8 TSQ3466… 25-nor C2…   37.6    11915     155542  22.0   102   11.0  4.50
##  9 TSQ3466… 28, 30 C2…   37.0    27403     343070  22.0   102   11.0  4.50
## 10 TSQ3466… 29, 30 C2…   35.8     5780      63220  22.0   102   11.0  4.50
## # ... with 7,604 more rows, and 25 more variables: maltene <dbl>,
## #   ref_amount_added.ug <dbl>, process <chr>, n_peaks <int>,
## #   n_standards <int>, ref_area.cpm <dbl>, amount.ug <dbl>,
## #   conc_rock.ug_g <dbl>, conc_tle.ug.g <dbl>, conc_maltene.ug.g <dbl>,
## #   calibration <chr>, data <list>, fit <list>, coefficients <list>,
## #   intercept <dbl>, intercept_se <dbl>, slope <dbl>, slope_se <dbl>,
## #   r2 <dbl>, total_volume.uL <dbl>, total_inject.uL <dbl>,
## #   ref_amount_inject_expected.ng <dbl>,
## #   ref_amount_inject_measured.ng <dbl>, ref_amount_measured.ug <dbl>,
## #   yield <dbl>

check yields

calib_data %>% 
  select(file_id, peak_name, yield)  %>% 
  arrange(file_id)  %>% 
  unique() %>% 
  ggplot() + aes(file_id, y = yield) +
  geom_point(size = 3) +
  theme_bw() + theme(axis.text.x = element_text(angle = 90, hjust = 0, vjust = 0.5))
## Warning: Removed 434 rows containing missing values (geom_point).

Combine compounds/make ratios (new rows w/o RTs etc, just concentration.rock column)

# functions to make it easy to sum up peaks

sum_peaks <- function(df, filter_condition, new_peak_name) {
  filter_condition <- sprintf("(%s)", str_c(filter_condition, collapse = "|"))
  filter(df, str_detect(peak_name, filter_condition)) %>% 
    summarize(
      file_id = file_id[1],
      depth = depth[1],
      conc_rock.ug_g = sum(conc_rock.ug_g)
    ) %>% 
    mutate(peak_name = new_peak_name)
}

ratio_peaks <- function(df, filter_top, filter_bottom, new_peak_name) {
  filter_top <- sprintf("(%s)", str_c(filter_top, collapse = "|"))
  filter_bottom <- sprintf("(%s)", str_c(filter_bottom, collapse = "|"))
  filter(df, str_detect(peak_name, filter_top) | str_detect(peak_name, filter_bottom)) %>% 
    summarize(
      file_id = file_id[1],
      depth = depth[1],
      ratio = sum(conc_rock.ug_g[str_detect(peak_name, filter_top)]) / sum(conc_rock.ug_g[str_detect(peak_name, filter_bottom)])
    ) %>% 
    mutate(peak_name = new_peak_name)
}

Ideas for other ratios? What about dimethyls?

#set values to use for later calculations
final_data1 <- calib_data %>% 
    group_by(file_id) %>% 
        do({
          bind_rows(., 
              #C27_Dia/Reg
                sum_peaks(.,  c("C27 aB 20R ST", "C27 aB 20S ST"), "C27Dia"),      
                sum_peaks(., c("C27 aaa 20R ST", "C27 aaa 20S ST", "C27 aBB 20R ST", "C27 aBB 20S ST", "C27 Ba 20R ST", "C27 Ba 20S ST"), "C27Reg"),
            
              #Total Tricyclics
                sum_peaks(., c("C19 Tri HO", "C20 Tri HO", "C21 Tri HO", "C22 Tri HO", "C23 Tri HO", "C24 Tet HO", "C24 Tri HO", "C25 Tri R HO", "C25 Tri S HO", "C26 Tri R HO", "C26 Tri S HO"), "all_tricyclics"),
            
              #4Me_TriMe
                sum_peaks(., c("4B Me 5a cholestane", "4B Me 24 ethyl 5a cholestane", "4B,23S,24S trimethyl 5a cholestane", "4B,23S,24R trimethyl 5a cholestane", "4B,23R,24S trimethyl 5a cholestane", "4B,23R,24R trimethyl 5a cholestane", "4a Me 5a cholestane", "4a Me 24 ethyl 5a cholestane", "4a,23S,24S trimethyl 5a cholestane", "4a,23S,24R trimethyl 5a cholestane", "4a,23R,24S trimethyl 5a cholestane", "4a,23R,24R trimethyl 5a cholestane"), "4Me_TriMe"),
            
              #allRegSt
                sum_peaks(., c("C26 aBB 20S ST", "C26 aBB 20R ST", "C26 aaa 20S ST", "C26 aaa 20R ST","C27 aBB 20S ST", "C27 aBB 20R ST", "C27 aaa 20S ST", "C27 aaa 20R ST", "C28 aBB 20S ST", "C28 aBB 20R ST", "C28 aaa 20S ST", "C28 aaa 20R ST","C29 aBB 20S ST", "C29 aBB 20R ST", "C29 aaa 20S ST", "C29 aaa 20R ST", "C30 aBB 20 R+S ST", "C30 aaa 20S ST", "C30 aaa 20R ST"), "allRegst"),
            
              #allRegHO
                sum_peaks(., c("Ts C27 HO", "Tm C27 HO", "C27 17B H Ho", "29, 30 C28H bisnor HO", "28, 30 C28 bisnor HO", "C29 Ts HO", "C29 Ba HO", "C29 BB Ho", "C30 aB HO", "C30 BB HO", "C30H Ba HO", "C31 HR Ba HO", "C31 aB HR HO", "C31 aB HS HO", "C31 BB HO", "C32 aB HS HO", "C32 aB HR HO", "C33 aB HS HO", "C33 aB HR HO", "C34 aB HR HO", "C34 aB HS HO", "C35 aB HR HO", "C35 aB HS HO"), "allRegHO") 
            
) }) %>% ungroup()
final_data <- final_data1 %>% 
    group_by(file_id) %>% 
        do({
          bind_rows(., 
            #Thermal Maturity
              #C27_Dia/Reg
                ratio_peaks(., "C27Dia", "C27Reg", "C27Dia/Reg"),
              #C27Dia_S/R
                ratio_peaks(., "C27 aB 20R ST", "C27 aB 20S ST", "C27Dia_S/R"),
              #C27Reg_abb/all 
                 ratio_peaks(., c("C27 aBB 20R ST", "C27 aBB 20S ST"), c("C27 aaa 20R ST", "C27 aaa 20S ST", "C27 aBB 20R ST", "C27 aBB 20S ST"), "C27Reg_abb/aaa"),
              #C27RegaaaS/S+R
                ratio_peaks(., "C27 aaa 20S ST", c("C27 aaa 20R ST", "C27 aaa 20S ST"), "C27Regaaa_S/S+R"), 
              #C27RegabbS/S+R
                ratio_peaks(., "C27 aBB 20S ST", c("C27 aBB 20S ST", "C27 aBB 20R ST"), "C27Regabb_S/S+R"),
              #C28Dia/all
                ratio_peaks(., c("C28 Ba 20S ST", "C28 Ba 20R ST"), c("C28 aBB 20S ST", "C28 aBB 20R ST", "C28 aaa 20S ST", "C28 aaa 20R ST", "C28 Ba 20S ST", "C28 Ba 20R ST"), "C28Dia/all"),
              #C28DiaS/S+R
                ratio_peaks(., "C28 Ba 20S ST", c("C28 Ba 20S ST", "C28 Ba 20R ST"), "C28DiaS/S+R"),
              #C28abb/all
                ratio_peaks(., c("C28 aBB 20S ST", "C28 aBB 20R ST"), c("C28 aBB 20S ST", "C28 aBB 20R ST", "C28 aaa 20S ST", "C28 aaa 20R ST"), "C28abb/all"),
              #C28aaaS/S+R
                ratio_peaks(., "C28 aaa 20S ST", c("C28 aaa 20S ST", "C28 aaa 20R ST"), "C28aaaS/S+R"),
              #C28abbS/S+R
                ratio_peaks(., "C28 aBB 20S ST", c("C28 aBB 20S ST", "C28 aBB 20R ST"), "C28abbS/S+R"),
              #C29Dia/all
                ratio_peaks(., c("C29 Ba 20S ST", "C29 Ba 20R ST"),  c("C29 Ba 20S ST", "C29 Ba 20R ST", "C29 aBB 20S ST", "C29 aBB 20R ST", "C29 aaa 20S ST", "C29 aaa 20R ST"), "C29Dia/all"),
              #C29DiaS/S+R
                ratio_peaks(., "C29 Ba 20S ST", c("C29 Ba 20S ST", "C29 Ba 20R ST"), "C29DiaS/S+R"),
              #C29abb/all
                ratio_peaks(., c("C29 aBB 20S ST", "C29 aBB 20R ST"), c( "C29 aaa 20S ST", "C29 aaa 20R ST", "C29 aBB 20S ST", "C29 aBB 20R ST" ), "C29abb/all"),
              #C29aaaS/S+R
                ratio_peaks(., "C29 aaa 20S ST", c("C29 aaa 20S ST", "C29 aaa 20R ST") , "C29aaaS/S+R"),
              #C29abbS/S+R
                ratio_peaks(., "C29 aBB 20S ST", c("C29 aBB 20S ST", "C29 aBB 20R ST"), "C29abbS/S+R"),
              #C27Ts/Ts+Tm
                ratio_peaks(., "Ts C27 HO", c("Ts C27 HO", "Tm C27  HO"), "C27Ts/Tm"),
              #C28BNH29,30/28,30
                ratio_peaks(., "29, 30 C28 bisnor HO", c("29, 30 C28 bisnor HO", "28, 30 C28 bisnor HO"), "C28BNH29,30/28,30"),
              #C29Ts/Ts+ab
                ratio_peaks(., "C29 Ts HO", c( "C29 aB HO", "C29 Ts HO"), "C29Ts/ab"),
              #C29ba/ba+ab
                ratio_peaks(.,"C29 Ba HO",  c("C29 aB HO", "C29 Ba HO"), "C29ba/ab"),
              #C29bb/bb+ab
                ratio_peaks(., "C29 BB Ho", c("C29 BB Ho", "C29 aB HO"), "C29bb/ab"),
              #C30_30nor/30nor+ab
                ratio_peaks(., "30-nor C30H HO", c("C30 aB HO", "30-nor C30H HO"),  "C30_30nor/ab"),
              #C30ba/ba+ab
                ratio_peaks(., "C30H Ba HO", c("C30 aB HO", "C30H Ba HO"), "C30ba/ab"),
              #C30bb/bb+ab
                ratio_peaks(., "C30 BB HO", c("C30 aB HO", "C30 BB HO"), "C30bb/ab"),
              #C31S/S+R
                ratio_peaks(., "C31 aB HS  HO", c("C31 aB HR HO", "C31 aB HS  HO"), "C31S/S+R"),
              #C32S/S+R
                ratio_peaks(., "C32 aB HS HO", c("C32 aB HS HO", "C32 aB HR HO"), "C32S/S+R"),
              #C33S/S+R
                ratio_peaks(., "C33 aB HS HO", c("C33 aB HS HO", "C33 aB HR HO"), "C33S/S+R"),
              #C34S/S+R
                ratio_peaks(., "C34 aB HS HO", c("C34 aB HS HO", "C34 aB HR HO") , "C34S/S+R"),
              #C35S/S+R
                ratio_peaks(., "C35 aB HS HO", c("C35 aB HS HO", "C35 aB HR HO") , "C35S/S+R")
          
              
 ) }) %>% ungroup() 
  
final_data
## # A tibble: 10,396 x 35
##    file_id  peak_name  RT.min area.cpm height.cts    OG depth rock.g   tle
##    <chr>    <chr>       <dbl>    <dbl>      <dbl> <dbl> <dbl>  <dbl> <dbl>
##  1 TSQ3466… 20R 4a,24…   34.7    42909     396389  22.0   102   11.0  4.50
##  2 TSQ3466… 20R, 4a M…   33.4    33439     425331  22.0   102   11.0  4.50
##  3 TSQ3466… 20R, 4a M…   32.8    49529     763046  22.0   102   11.0  4.50
##  4 TSQ3466… 20R, 4a,2…   35.3    26212     404760  22.0   102   11.0  4.50
##  5 TSQ3466… 20S, 4a M…   32.1    49207     882869  22.0   102   11.0  4.50
##  6 TSQ3466… 20S, 4a,2…   35.8    31831     268610  22.0   102   11.0  4.50
##  7 TSQ3466… 20S, 4a,2…   34.0    51613     456842  22.0   102   11.0  4.50
##  8 TSQ3466… 25-nor C2…   37.6    11915     155542  22.0   102   11.0  4.50
##  9 TSQ3466… 28, 30 C2…   37.0    27403     343070  22.0   102   11.0  4.50
## 10 TSQ3466… 29, 30 C2…   35.8     5780      63220  22.0   102   11.0  4.50
## # ... with 10,386 more rows, and 26 more variables: maltene <dbl>,
## #   ref_amount_added.ug <dbl>, process <chr>, n_peaks <int>,
## #   n_standards <int>, ref_area.cpm <dbl>, amount.ug <dbl>,
## #   conc_rock.ug_g <dbl>, conc_tle.ug.g <dbl>, conc_maltene.ug.g <dbl>,
## #   calibration <chr>, data <list>, fit <list>, coefficients <list>,
## #   intercept <dbl>, intercept_se <dbl>, slope <dbl>, slope_se <dbl>,
## #   r2 <dbl>, total_volume.uL <dbl>, total_inject.uL <dbl>,
## #   ref_amount_inject_expected.ng <dbl>,
## #   ref_amount_inject_measured.ng <dbl>, ref_amount_measured.ug <dbl>,
## #   yield <dbl>, ratio <dbl>

Against depth

ratios etc

C27Dia/Reg

dia<- subset(final_data, peak_name== "C27Dia/Reg") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(dia)
diareg <- subset(final_data, peak_name %in% c("C27Dia", "C27Reg")) %>%
  ggplot() +
  aes(x = conc_rock.ug_g, y = depth, color = peak_name) +
  geom_point() +
  #facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(diareg)
# test checks
outcome <- calib_data %>% 
  group_by(file_id) %>%
  select(file_id, peak_name, depth, area.cpm, conc_rock.ug_g) %>% 
  do({
    bind_rows(., 
            ratio_peaks(., "C27 aB 20R ST", "C27 aB 20S ST", "C27Dia_S/R")
    )
  }) %>% 
  filter(#!str_detect(file_id, "TSQ3779"),  
         str_detect(peak_name, "C27Dia_S/R")) 
         #str_detect(peak_name, "aB"))
outcome
## # A tibble: 81 x 6
## # Groups:   file_id [70]
##    file_id          peak_name  depth area.cpm conc_rock.ug_g  ratio
##    <chr>            <chr>      <dbl>    <dbl>          <dbl>  <dbl>
##  1 TSQ3466_GB_OG022 C27Dia_S/R 102         NA             NA 0.145 
##  2 TSQ3467_GB_OG023 C27Dia_S/R 101         NA             NA 0.151 
##  3 TSQ3468_GB_OG025 C27Dia_S/R  98.9       NA             NA 0.170 
##  4 TSQ3469_GB_OG026 C27Dia_S/R  98.1       NA             NA 0.0327
##  5 TSQ3472_GB_OG027 C27Dia_S/R  96.9       NA             NA 0.0330
##  6 TSQ3473_GB_OG019 C27Dia_S/R 105         NA             NA 0     
##  7 TSQ3474_GB_OG020 C27Dia_S/R 104         NA             NA 0.0227
##  8 TSQ3475_GB_OG021 C27Dia_S/R 103         NA             NA 0.0448
##  9 TSQ3476_GB_OG018 C27Dia_S/R 106         NA             NA 0.0335
## 10 TSQ3481_GB_OG002 C27Dia_S/R 125         NA             NA 0.111 
## # ... with 71 more rows

DiaS/S+R

diasr <- final_data %>% 
  filter(depth != c(116.490, 116.900)) %>%
  filter(peak_name %in% c("C27Dia_S/R" , "C28DiaS/S+R" , "C29DiaS/S+R")) %>%
  ggplot() +
  aes(x = ratio, y = depth, color = peak_name) +
  geom_point() +
  #facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(diasr)

C27Regabb/aaa

twentyseven<- subset(final_data, peak_name== "C27Reg_abb/aaa") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(twentyseven)

#aaa_S/S+R

aaa<- final_data %>%
  filter(peak_name %in% c("C27Regaaa_S/S+R", "C28aaaS/S+R", "C29aaaS/S+R")) %>%
  ggplot() +
  aes(x = ratio, y = depth, color = peak_name) +
  geom_point() +
  facet_grid(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(aaa)

###abb_s/s+r

abb <- subset(final_data, peak_name %in% c("C27Regabb_S/S+R", "C28abbS/S+R", "C29abbS/S+R")) %>%
  ggplot() +
  aes(x = ratio, y = depth, color = peak_name) +
  geom_point() +
  #facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(abb)

C28/9Dia/all

Dia <- subset(final_data, peak_name %in% c("C28Dia/all", "C29Dia/all")) %>%
  ggplot() +
  aes(x = depth, y = ratio, color = peak_name) +
  geom_point() +
  geom_smooth() +
  #facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()

ggplotly(Dia)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 36 rows containing non-finite values (stat_smooth).

C28/9abb/all

subset(final_data, peak_name %in% c("C28abb/all", "C29abb/all"))  %>%
  ggplot() +
  aes(x = ratio, y = depth, color = peak_name) +
  geom_point() +
  #facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
## Warning: Removed 36 rows containing missing values (geom_point).

C27Ts/Tm

tstm <- subset(final_data, peak_name== "C27Ts/Tm") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
ggplotly(tstm)

C28BNH29,30/28,30

bnh <- subset(final_data, peak_name== "C28BNH29,30/28,30") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(bnh)

C29Ts/ab

tsab<- subset(final_data, peak_name== "C29Ts/ab") %>%
  ggplot() +
  aes(x = depth, y = ratio) +
  geom_point() +
  geom_line() +
  facet_wrap(~peak_name, scales = "free") +
  scale_x_reverse() +
  coord_flip()
ggplotly(tsab)

C29,30ba/ab

baab <- subset(final_data, peak_name %in% c("C29ba/ab", "C30ba/ab")) %>%
  ggplot() +
  aes(x = ratio, y = depth, color = peak_name) +
  geom_point() +
  #facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(baab)

C29bb/ab

bbab <- subset(final_data, peak_name %in% c("C29bb/ab", "C30bb/ab")) %>%
  ggplot() +
  aes(x = ratio, y = depth, color = peak_name) +
  geom_point() +
  #facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(bbab)

C30_30nor/ab

thirtynor <- subset(final_data, peak_name== "C30_30nor/ab") %>%
  ggplot() +
  aes(x = ratio, y = depth) +
  geom_point() +
  facet_wrap(~peak_name, scales = "free") +
  scale_y_reverse()
ggplotly(thirtynor)
subset(final_data, peak_name %in% c("C30 aB HO", "C30H Ba HO")) %>%
  ggplot() +
  aes(x = area.cpm, y = depth, color = peak_name) +
  geom_point() +
  #facet_wrap(~peak_name) +
  scale_y_reverse()
## Warning: Removed 18 rows containing missing values (geom_point).

All Ho S/R

srho <- final_data %>%
  filter(peak_name %in% c("C31S/S+R", "C32S/S+R", "C33S/S+R", "C34S/S+R", "C35S/S+R")) %>%
  ggplot() +
  aes(x = depth, y = ratio, color = peak_name) +
  geom_point() +
  geom_line() +
  #facet_grid(~peak_name) +
  scale_x_reverse() +
  coord_flip()
ggplotly(srho)